﻿<div style="width:600px;margin:0 auto;padding-top:20px;">
    <form class="layui-form" action="">
        <div class="layui-form-item">
        	<label class="layui-form-label">项目名称</label>
        	<div class="layui-input-block">
        		<input type="hidden" name="id" />
				<input type="text" name="name" readonly="readonly" win-verify="required" autocomplete="off" class="layui-input" />
			</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">灰度标示</label>
            <div class="layui-input-block">
            	<input type="text" name="flag" readonly="readonly" win-verify="required" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">类型</label>
            <div class="layui-input-block winui-radio">
                <input type="radio" name="type" value="ip" title="IP" checked/>
                <input type="radio" name="type" value="keyInRequest" title="KeyInRequest" />
                <input type="radio" name="type" value="keyInSession" title="KeyInSession" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">参数关键字</label>
            <div class="layui-input-block">
                <input type="text" name="key" placeholder="请输入一个参数关键字" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">参数值</label>
            <div class="layui-input-block">
                <input type="text" name="value" placeholder="请输入参数值，多个用英文逗号分开" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="winui-btn" lay-submit lay-filter="formEditMenu">确定</button>
                <button class="winui-btn" onclick="winui.window.close('editMenu'); return false;">取消</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form'], function (form) {
        var msg = winui.window.msg,
            $ = layui.$;
        form.render();
        form.on('submit(formEditMenu)', function (data) {
            console.log(data);
            //表单验证
            if (winui.verifyForm(data.elem)) {
                layui.$.ajax({
                    type: 'post',
                    url: '/canary/update',
                    contentType: 'application/json;charset=utf-8',
                    async: false,
                    data: JSON.stringify(data.field),
                    dataType: 'json',
                    success: function (json) {
                        if (json.success) {
                            msg('修改成功', {
                                icon: 1,
                                time: 2000
                            });
                        } else {
                            msg(json.message);
                        }
                        winui.window.close('editMenu');
                    },
                    error: function (xml) {
                        msg(xml.responseText == "" ? "获取页面失败" : xml.responseText, {
                            icon: 2,
                            time: 2000
                        });
                    }
                });
            }
            return false;
        });
    });
</script>